home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / Source.bin / HorizontalSpinButtonPanel.java < prev    next >
Text File  |  1998-08-21  |  3KB  |  103 lines

  1. package symantec.itools.awt.util.spinner;
  2.  
  3. import java.awt.Dimension;
  4.  
  5. //    06/03/97    LAB Changed the package to symantec.itools.awt.util.spinner.
  6. //    08/27/97    LAB    Removed unnecessary imports.  Now uses the preferred sizes of the direction
  7. //                    buttons it contains when reshaping or when asked it's preferred size.
  8. //                    Updated version to 1.1.
  9. //  08/28/97    LAB    Updated version to 1.1. Updated reshape.  Implemented getPreferredSize and
  10. //                    getMinimumSize.
  11. //  10/12/97    LAB    Changed reshape and getPreferredSize to follow changes with Spinner.java.
  12.  
  13. /**
  14.  * This component groups two spin buttons horizontally. It is used for
  15.  * spinners with the ORIENTATION_HORIZONTAL attribute set.
  16.  *
  17.  * @see Spinner
  18.  * @see symantec.itools.awt.Orientation
  19.  * @see symantec.itools.awt.Orientation#ORIENTATION_HORIZONTAL
  20.  *
  21.  * @version 1.1, August 27, 1997
  22.  * @author Symantec
  23.  */
  24. public class HorizontalSpinButtonPanel extends SpinButtonPanel
  25. {
  26.     /**
  27.      * Constructs the default HorizontalSpinButtonPanel.
  28.      */
  29.     public HorizontalSpinButtonPanel()
  30.     {
  31.     }
  32.  
  33.     /**
  34.      * Moves and/or resizes this component.
  35.      * This is a standard Java AWT method which gets called to move and/or
  36.      * resize this component. Components that are in containers with layout
  37.      * managers should not call this method, but rely on the layout manager
  38.      * instead.
  39.      *
  40.      * This method is overridden to reshape the two direction buttons.
  41.      *
  42.      * @param x horizontal position in the parent's coordinate space
  43.      * @param y vertical position in the parent's coordinate space
  44.      * @param width the new width
  45.      * @param height the new height
  46.      */
  47.     public void reshape(int x, int y, int width, int height)
  48.     {
  49.         int calcDim    = (int)(height * heightWidthRatio);
  50.         int yAdj        = (height - calcDim) / 2;
  51.  
  52.         incButton.setBounds(0, yAdj, calcDim, calcDim);
  53.         decButton.setBounds(calcDim, yAdj, calcDim, calcDim);
  54.  
  55.         super.reshape(x, y, width + width, height);
  56.     }
  57.  
  58.     /**
  59.      * Returns the recommended dimensions to properly display this component.
  60.      * This is a standard Java AWT method which gets called to determine
  61.      * the recommended size of this component.
  62.      */
  63.     public Dimension getPreferredSize()
  64.     {
  65.         int height = getSize().height;
  66.         int calcDim = (int)(height * heightWidthRatio);
  67.  
  68.         return new Dimension(calcDim + calcDim, height);
  69.     }
  70.  
  71.     /**
  72.      * Returns the minimum dimensions to properly display this component.
  73.      * This is a standard Java AWT method which gets called to determine
  74.      * the minimum size of this component.
  75.      * It simply returns the results of a call to preferedSize().
  76.      */
  77.     public Dimension getMinimumSize()
  78.     {
  79.         return getPreferredSize();
  80.     }
  81.     
  82.     /**
  83.      * @deprecated
  84.      * @see #getPreferredSize().
  85.      */
  86.     public Dimension preferredSize()
  87.     {
  88.         return getPreferredSize();
  89.     }
  90.  
  91.     /**
  92.      * @deprecated
  93.      * @see #getMinimumSize().
  94.      */
  95.     public Dimension minimumSize()
  96.     {
  97.         return getMinimumSize();
  98.     }
  99.     /**
  100.      * The ratio of height to width of the spinner buttons.  i.e. height is <ratio> * width.
  101.      */
  102.     protected double heightWidthRatio = 0.75;
  103. }